package westh.ilib.struts.action.zhangjiao;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.mule.extras.client.MuleClient;
import org.mule.impl.MuleMessage;
import org.mule.umo.UMOMessage;

import westh.util.YyAction;
/**
 * @author zhangjiao
 * 
 */

public class SaveLogAction extends Action {
	private final static Log log = LogFactory.getLog(SaveLogAction.class);
	
	public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) {

		//得到输入的Json-串
		DynaActionForm f = (DynaActionForm) form;
		String inputStr = f.getString("inputStr");
		//jSon-String
		String outString = "";
		/**************获取jSon信息 start***************************/		
		try {
			MuleClient client = new MuleClient();
			//调用WebService
			UMOMessage umo = client.send("axis:http://166.111.134.22:5181/Test/yyiLibTest?method=saveLog",inputStr,null);
			outString = (String)umo.getPayload();

	
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		/**************获取jSon信息 end***************************/
		
		
		if (outString.length()!= 0) {
			String info = "获取信息成功！";
			log.debug(info);
			request.setAttribute("outString", outString);
			return mapping.findForward("succ");
		} else {
			String info = "获取信息失败！";
			log.debug(info);
			request.setAttribute("info", info);
			return mapping.findForward("fail");
		}
		
	}

}
